defmodule IocpMonitor.Dumper.WorkerSupervisor do
  @moduledoc """
  实时数据存储工作进程的监护进程定义模块
  """

  use Supervisor

  alias IocpMonitor.Dumper.Worker

  def start_link(workers_count) do
    Supervisor.start_link(__MODULE__, workers_count, name: __MODULE__)
  end

  @impl true
  def init(workers_count) do
    children = (1..workers_count)
               |> Enum.map(fn(n)-> Supervisor.child_spec({Worker, nil}, id: n) end)
    Supervisor.init(children, strategy: :one_for_one)
  end
end